import React from 'react';
import classNames from 'classnames';

class Item extends React.Component {
    displayName = 'Item';

    render () {
        const {data, offset, level, onSelectMenu} = this.props;
        const clazzName = classNames('cm-menu-item', data.className, {
            'cm-menu-item-active': data.selected,
            'cm-menu-item-disabled': data.disabled
        });
        const style = data.style || {};
        level ? style.paddingLeft = offset * level : false;
        return <li className={clazzName} style={style} onClick={onSelectMenu && onSelectMenu.bind(this, this, data)}>
            {data.text}
        </li>;
    }
}

export default Item;
